﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<div class="modal-dialog x-modal-dialog" style="width:600px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb no-bottom-border clearfix">

      <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>编辑门店&nbsp;-&nbsp;营业时间</span></h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="POST" action="${ctx.host}/sites/${site.id}/edit-business-hour" data-validate="true">
    
      <input type="hidden" name="_method" value="PATCH">
      <input type="hidden" name="siteId" value="${site.id}">
      
      <div class="modal-body">
        
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">营业时间</label>
          <div class="col-xs-8 input-group" style="padding: 0 15px; ">
             <select name="businessStartHour" class="form-control"  aria-describedby="basic-addon2" data-validate="required">
              <option></option>
              <c:forEach begin="0" end="24" varStatus="status">
                <c:set var="hour" value="${status.index}:00"></c:set>
                <c:set var="halfhour" value="${status.index}:30"></c:set>
                <option value="${hour}" ${site.businessStartHour eq hour ? 'selected' : ''}>${status.index}:00</option>
                <c:if test="${status.index != 24}">
                  <option value="${halfhour}" ${site.businessStartHour eq halfhour ? 'selected' : ''}>${status.index}:30</option>
                </c:if>
              </c:forEach>
             </select>
             <span class="input-group-addon" id="basic-addon2">至</span>
             <select name="businessEndHour" class="form-control"  aria-describedby="basic-addon2" data-validate="required">
              <option></option>
              <c:forEach begin="0" end="24" varStatus="status">
                <c:set var="hour" value="${status.index}:00"></c:set>
                <c:set var="halfhour" value="${status.index}:30"></c:set>
                <option value="${hour}" ${site.businessEndHour eq hour ? 'selected' : ''}>${status.index}:00</option>
                <c:if test="${status.index != 24}">
                  <option value="${halfhour}" ${site.businessEndHour eq halfhour ? 'selected' : ''}>${status.index}:30</option>
                </c:if>
              </c:forEach>
            </select>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">可预约时间</label>
          <div class="col-xs-8 input-group" style="padding: 0 15px; ">
             <select name="appointStartHour" class="form-control"  aria-describedby="basic-addon2" data-validate="required">
              <option></option>
              <c:forEach begin="0" end="24" varStatus="status">
                <c:set var="hour" value="${status.index}:00"></c:set>
                <c:set var="halfhour" value="${status.index}:30"></c:set>
                <option value="${hour}" ${site.appointStartHour eq hour ? 'selected' : ''}>${status.index}:00</option>
                <c:if test="${status.index != 24}">
                  <option value="${halfhour}" ${site.appointStartHour eq halfhour ? 'selected' : ''}>${status.index}:30</option>
                </c:if>
              </c:forEach>
             </select>
             <span class="input-group-addon" id="basic-addon2">至</span>
             <select name="appointEndHour" class="form-control"  aria-describedby="basic-addon2" data-validate="required">
              <option></option>
              <c:forEach begin="0" end="24" varStatus="status">
                <c:set var="hour" value="${status.index}:00"></c:set>
                <c:set var="halfhour" value="${status.index}:30"></c:set>
                <option value="${hour}" ${site.appointEndHour eq hour ? 'selected' : ''}>${status.index}:00</option>
                <c:if test="${status.index != 24}">
                  <option value="${halfhour}" ${site.appointEndHour eq halfhour ? 'selected' : ''}>${status.index}:30</option>
                </c:if>
              </c:forEach>
            </select>
          </div>
        </div>
        
      </div>

      <div class="modal-footer">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>
    </form>

  </div>

</div>
<script>
    $('select[name="businessStartHour"], select[name="businessEndHour"]').select2({
      placeholder : '请选择营业时间',
      minimumResultsForSearch : 5,
      allowClear : true
    });
    $('select[name="appointStartHour"], select[name="appointEndHour"]').select2({
        placeholder : '请选择可预约时间',
        minimumResultsForSearch : 5,
        allowClear : true
      });
</script>
